home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 5 June, 1997
- // Author: jb
- //
- // Description:
- // This script is a template script for option box dialogs.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
-
- proc setOptionVars (int $forceFactorySettings)
- {
- if( $forceFactorySettings || !`optionVar -exists phongRed` ) {
- optionVar -floatValue phongRed 0.5;
- }
- if( $forceFactorySettings || !`optionVar -exists phongGreen` ) {
- optionVar -floatValue phongGreen 0.5;
- }
- if( $forceFactorySettings || !`optionVar -exists phongBlue` ) {
- optionVar -floatValue phongBlue 0.5;
- }
- if( $forceFactorySettings || !`optionVar -exists phongTransRed` ) {
- optionVar -floatValue phongTransRed 0.0;
- }
- if( $forceFactorySettings || !`optionVar -exists phongTransGreen` ) {
- optionVar -floatValue phongTransGreen 0.0;
- }
- if( $forceFactorySettings || !`optionVar -exists phongTransBlue` ) {
- optionVar -floatValue phongTransBlue 0.0;
- }
- if( $forceFactorySettings || !`optionVar -exists phongAmbientRed` ) {
- optionVar -floatValue phongAmbientRed 0.0;
- }
- if( $forceFactorySettings || !`optionVar -exists phongAmbientGreen` ) {
- optionVar -floatValue phongAmbientGreen 0.0;
- }
- if( $forceFactorySettings || !`optionVar -exists phongAmbientBlue` ) {
- optionVar -floatValue phongAmbientBlue 0.0;
- }
- if( $forceFactorySettings || !`optionVar -exists phongIncandRed` ) {
- optionVar -floatValue phongIncandRed 0.0;
- }
- if( $forceFactorySettings || !`optionVar -exists phongIncandGreen` ) {
- optionVar -floatValue phongIncandGreen 0.0;
- }
- if( $forceFactorySettings || !`optionVar -exists phongIncandBlue` ) {
- optionVar -floatValue phongIncandBlue 0.0;
- }
- if( $forceFactorySettings || !`optionVar -exists phongSpecularRed` ) {
- optionVar -floatValue phongSpecularRed 0.0;
- }
- if( $forceFactorySettings || !`optionVar -exists phongSpecularGreen` ) {
- optionVar -floatValue phongSpecularGreen 0.0;
- }
- if( $forceFactorySettings || !`optionVar -exists phongSpecularBlue` ) {
- optionVar -floatValue phongSpecularBlue 0.0;
- }
- if( $forceFactorySettings || !`optionVar -exists phongCosinePower` ) {
- optionVar -floatValue phongCosinePower 20.0;
- }
- if( $forceFactorySettings || !`optionVar -exists phongRoughness` ) {
- optionVar -floatValue phongRoughness 0.5;
- }
- if( $forceFactorySettings || !`optionVar -exists phongHighlightSize` ) {
- optionVar -floatValue phongHighlightSize 0.5;
- }
- if( $forceFactorySettings || !`optionVar -exists phongWhitenessRed` ) {
- optionVar -floatValue phongWhitenessRed 0.5;
- }
- if( $forceFactorySettings || !`optionVar -exists phongWhitenessGreen` ) {
- optionVar -floatValue phongWhitenessGreen 0.5;
- }
- if( $forceFactorySettings || !`optionVar -exists phongWhitenessBlue` ) {
- optionVar -floatValue phongWhitenessBlue 0.5;
- }
- if( $forceFactorySettings || !`optionVar -exists phongReflectivity` ) {
- optionVar -floatValue phongReflectivity 0.5;
- }
- if( $forceFactorySettings || !`optionVar -exists phongType` ) {
- optionVar -stringValue phongType "regularPhong";
- }
- }
-
- global proc createPhongSetup (string $parent, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars( $forceFactorySettings );
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls
- //
- float $red = `optionVar -query phongRed`;
- float $green = `optionVar -query phongGreen`;
- float $blue = `optionVar -query phongBlue`;
- colorSliderGrp -e -rgb $red $green $blue phongRGB;
-
- $red = `optionVar -query phongTransRed`;
- $green = `optionVar -query phongTransGreen`;
- $blue = `optionVar -query phongTransBlue`;
- colorSliderGrp -e -rgb $red $green $blue phongTransRGB;
-
- $red = `optionVar -query phongAmbientRed`;
- $green = `optionVar -query phongAmbientGreen`;
- $blue = `optionVar -query phongAmbientBlue`;
- colorSliderGrp -e -rgb $red $green $blue phongAmbientRGB;
-
- $red = `optionVar -query phongIncandRed`;
- $green = `optionVar -query phongIncandGreen`;
- $blue = `optionVar -query phongIncandBlue`;
- colorSliderGrp -e -rgb $red $green $blue phongIncandRGB;
-
- $red = `optionVar -query phongSpecularRed`;
- $green = `optionVar -query phongSpecularGreen`;
- $blue = `optionVar -query phongSpecularBlue`;
- colorSliderGrp -e -rgb $red $green $blue phongSpecularRGB;
-
- floatSliderGrp -e -v `optionVar -q phongCosinePower` phongCosinePower;
- floatSliderGrp -e -v `optionVar -q phongRoughness` phongRoughness;
- floatSliderGrp -e -v `optionVar -q phongHighlightSize` phongHighlightSize;
-
- $red = `optionVar -query phongWhitenessRed`;
- $green = `optionVar -query phongWhitenessGreen`;
- $blue = `optionVar -query phongWhitenessBlue`;
- colorSliderGrp -e -rgb $red $green $blue phongWhitenessRGB;
-
- floatSliderGrp -e -v `optionVar -q phongReflectivity` phongReflectivity;
-
- string $phongType = `optionVar -query phongType`;
- if( $phongType == "regularPhong" ) {
- radioButtonGrp -e -sl 1 phongType;
- } else {
- radioButtonGrp -e -sl 2 phongType;
- }
-
- // Disable and enable some widgets, depending on the
- // setting of the regular vs explore phong buttons
- //
- if( $phongType == "regularPhong" ) {
- floatSliderGrp -e -enable false phongRoughness;
- floatSliderGrp -e -enable false phongHighlightSize;
- colorSliderGrp -e -enable false phongWhitenessRGB;
- floatSliderGrp -e -enable true phongCosinePower;
- } else {
- floatSliderGrp -e -enable true phongRoughness;
- floatSliderGrp -e -enable true phongHighlightSize;
- colorSliderGrp -e -enable true phongWhitenessRGB;
- floatSliderGrp -e -enable false phongCosinePower;
- }
- }
-
- global proc createPhongCallback (string $parent, int $doIt)
- //
- // Description:
- // Set the optionVar's from the control values, and then perform
- // the command
- //
- {
- setParent $parent;
-
- float $rgb[] = `colorSliderGrp -q -rgb phongRGB`;
- optionVar -floatValue phongRed $rgb[0];
- optionVar -floatValue phongGreen $rgb[1];
- optionVar -floatValue phongBlue $rgb[2];
-
- $rgb = `colorSliderGrp -q -rgb phongTransRGB`;
- optionVar -floatValue phongTransRed $rgb[0];
- optionVar -floatValue phongTransGreen $rgb[1];
- optionVar -floatValue phongTransBlue $rgb[2];
-
- $rgb = `colorSliderGrp -q -rgb phongAmbientRGB`;
- optionVar -floatValue phongAmbientRed $rgb[0];
- optionVar -floatValue phongAmbientGreen $rgb[1];
- optionVar -floatValue phongAmbientBlue $rgb[2];
-
- $rgb = `colorSliderGrp -q -rgb phongSpecularRGB`;
- optionVar -floatValue phongSpecularRed $rgb[0];
- optionVar -floatValue phongSpecularGreen $rgb[1];
- optionVar -floatValue phongSpecularBlue $rgb[2];
-
- $rgb = `colorSliderGrp -q -rgb phongIncandRGB`;
- optionVar -floatValue phongIncandRed $rgb[0];
- optionVar -floatValue phongIncandGreen $rgb[1];
- optionVar -floatValue phongIncandBlue $rgb[2];
-
- optionVar -floatValue phongCosinePower `floatSliderGrp -q -v phongCosinePower`;
- optionVar -floatValue phongRoughness `floatSliderGrp -q -v phongRoughness`;
- optionVar -floatValue phongHighlightSize `floatSliderGrp -q -v phongHighlightSize`;
-
- $rgb = `colorSliderGrp -q -rgb phongWhitenessRGB`;
- optionVar -floatValue phongWhitenessRed $rgb[0];
- optionVar -floatValue phongWhitenessGreen $rgb[1];
- optionVar -floatValue phongWhitenessBlue $rgb[2];
-
- optionVar -floatValue phongReflectivity `floatSliderGrp -q -v phongReflectivity`;
-
- int $phongType = `radioButtonGrp -q -sl phongType`;
- if( $phongType == 1 ) {
- optionVar -stringValue phongType "regularPhong";
- } else {
- optionVar -stringValue phongType "explorePhong";
- }
-
- if( $doIt ) {
- performCreatePhong 0;
- }
- }
-
- global proc createPhongOptions ()
- {
- // Name of the command for this option box
- //
- string $commandName = "createPhong";
-
- // Build the option box "methods"
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // STEP 1: Get the option box.
- // ============================
- //
- // The value returned is the name of the layout to be used as
- // the parent for the option box UI.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // STEP 2: Pass the command name to the option box.
- // =================================================
- //
- // Any default option box behaviour based on the command name is set
- // up with this call. For example, updating the 'Help' menu item with
- // the name of the command.
- //
- setOptionBoxCommandName($commandName);
-
- // STEP 3: Activate the default UI template.
- // ==========================================
- //
- // Activate the default UI template so that the layout of this
- // option box is consistent with the layout of the rest of the
- // application.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // STEP 4: Create option box contents.
- // ===================================
- //
- // This, of course, will vary from option box to option box.
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- // Create the widgets for this option box
- //
- separator -style "none" -h 5;
-
- radioButtonGrp
- -label "Phong Type"
- -numberOfRadioButtons 2
- -select 1
- -la2 "Regular" "Explore"
- phongType;
-
- radioButtonGrp -edit
- -cc1 ( "floatSliderGrp -e -enable false phongRoughness; "+
- "floatSliderGrp -e -enable false phongHighlightSize; "+
- "colorSliderGrp -e -enable false phongWhitenessRGB; "+
- "floatSliderGrp -e -enable true phongCosinePower; " )
- -cc2 ( "floatSliderGrp -e -enable true phongRoughness; "+
- "floatSliderGrp -e -enable true phongHighlightSize; "+
- "colorSliderGrp -e -enable true phongWhitenessRGB; "+
- "floatSliderGrp -e -enable false phongCosinePower; " )
- phongType;
-
- colorSliderGrp
- -h 25
- -label "Color"
- -rgb 0.5 0.5 0.5
- phongRGB;
-
- colorSliderGrp
- -h 25
- -label "Transparency"
- -rgb 0 0 0
- phongTransRGB;
-
- colorSliderGrp
- -h 25
- -label "Ambient Color"
- -rgb 0 0 0
- phongAmbientRGB;
-
- colorSliderGrp
- -h 25
- -label "Incandescence"
- -rgb 0 0 0
- phongIncandRGB;
-
- separator -style "in" -h 5;
-
- colorSliderGrp
- -h 25
- -label "Specular Color"
- -rgb 0.5 0.5 0.5
- phongSpecularRGB;
-
- floatSliderGrp
- -h 25
- -label "Reflectivity"
- -field true
- -value 0.5
- -min 0.0 -max 1.0
- -pre 4
- phongReflectivity;
-
- floatSliderGrp
- -h 25
- -label "Cosine Power"
- -field true
- -value 20.0
- -min 2.0 -max 100.0
- -pre 4
- phongCosinePower;
-
- floatSliderGrp
- -h 25
- -label "Roughness"
- -field true
- -value 0.5
- -min 0.0 -max 1.0
- -pre 4
- phongRoughness;
-
- floatSliderGrp
- -h 25
- -label "Highlight Size"
- -field true
- -value 0.5
- -min 0.0 -max 1.0
- -pre 4
- phongHighlightSize;
-
- colorSliderGrp
- -h 25
- -label "Whiteness"
- -rgb 0.5 0.5 0.5
- phongWhitenessRGB;
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
- //
- // Provide more descriptive labels for the buttons. This is not
- // necessary, but in some cases, for example, a button labelled
- // 'Create' may be more meaningful to the user than one labelled
- // 'Apply'.
- //
- // Disable those buttons that are not applicable to the option box.
- //
- // Attach actions to those buttons that are applicable to the option
- // box. Note that the 'Close' button has a default action attached
- // to it that will hide the window. If a a custom action is
- // attached to the 'Close' button then be sure to call the 'hide the
- // option box' procedure within the custom action so that the option
- // box is hidden properly.
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit -label "Create"
- -command ($callback + " " + $parent + " " + 1)
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- setOptionBoxTitle("Create Phong Shader Options");
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- eval (($setup + " " + $parent + " " + 0));
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
- proc string getCmd()
- {
- string $cmd;
-
- setOptionVars( false );
-
- float $red = `optionVar -query phongRed`;
- float $green = `optionVar -query phongGreen`;
- float $blue = `optionVar -query phongBlue`;
- float $transR = `optionVar -query phongTransRed`;
- float $transG = `optionVar -query phongTransGreen`;
- float $transB = `optionVar -query phongTransBlue`;
- float $ambR = `optionVar -query phongAmbientRed`;
- float $ambG = `optionVar -query phongAmbientGreen`;
- float $ambB = `optionVar -query phongAmbientBlue`;
- float $incandR = `optionVar -query phongIncandRed`;
- float $incandG = `optionVar -query phongIncandGreen`;
- float $incandB = `optionVar -query phongIncandBlue`;
- float $specR = `optionVar -query phongSpecularRed`;
- float $specG = `optionVar -query phongSpecularGreen`;
- float $specB = `optionVar -query phongSpecularBlue`;
- float $cosinePower = `optionVar -query phongCosinePower`;
- float $roughness = `optionVar -query phongRoughness`;
- float $highlightSize = `optionVar -query phongHighlightSize`;
- float $whitenessR = `optionVar -query phongWhitenessRed`;
- float $whitenessG = `optionVar -query phongWhitenessGreen`;
- float $whitenessB = `optionVar -query phongWhitenessBlue`;
- float $reflectivity = `optionVar -query phongReflectivity`;
-
- $cmd = "{string $result;";
-
- string $phongType = `optionVar -query phongType`;
- if( $phongType == "regularPhong" ) {
- $cmd = $cmd + "$result = `shadingNode -asShader phong`;";
- } else {
- $cmd = $cmd + "$result = `shadingNode -asShader phongE`;";
- }
-
- $cmd = $cmd + "string $SEName = `sets -renderable true -name ($result+\"Grp\") -empty`;";
- $cmd = $cmd + "connectAttr -f ( $result + \".outColor\") ( $SEName + \".surfaceShader\" );";
-
- // string $SEName = `sets -renderable true -name ($result+"Grp") -empty`;
- // connectAttr -f ( $result+".outColor" ) ( $SEName+".surfaceShader" );
-
- // Set the attributes the from the optionVars set
- // in the optionBox
- //
- $cmd = $cmd + "setAttr ( $result+\".colorR\" ) " + $red + ";";
- $cmd = $cmd + "setAttr ( $result+\".colorG\" ) " + $green + ";";
- $cmd = $cmd + "setAttr ( $result+\".colorB\" ) " + $blue + ";";
- $cmd = $cmd + "setAttr ( $result+\".transparencyR\" ) " + $transR + ";";
- $cmd = $cmd + "setAttr ( $result+\".transparencyG\" ) " + $transG + ";";
- $cmd = $cmd + "setAttr ( $result+\".transparencyB\" ) " + $transB + ";";
- $cmd = $cmd + "setAttr ( $result+\".ambientColorR\" ) " + $ambR + ";";
- $cmd = $cmd + "setAttr ( $result+\".ambientColorG\" ) " + $ambG + ";";
- $cmd = $cmd + "setAttr ( $result+\".ambientColorB\" ) " + $ambB + ";";
- $cmd = $cmd + "setAttr ( $result+\".incandescenceR\" ) " + $incandR + ";";
- $cmd = $cmd + "setAttr ( $result+\".incandescenceG\" ) " + $incandG + ";";
- $cmd = $cmd + "setAttr ( $result+\".incandescenceB\" ) " + $incandB + ";";
- $cmd = $cmd + "setAttr ( $result+\".specularColorR\" ) " + $specR + ";";
- $cmd = $cmd + "setAttr ( $result+\".specularColorG\" ) " + $specG + ";";
- $cmd = $cmd + "setAttr ( $result+\".specularColorB\" ) " + $specB + ";";
- if( $phongType == "regularPhong" ) {
- $cmd = $cmd + "setAttr ( $result+\".cosinePower\" ) " + $cosinePower + ";";
- } else {
- $cmd = $cmd + "setAttr ( $result+\".roughness\" ) " + $roughness + ";";
- $cmd = $cmd + "setAttr ( $result+\".highlightSize\" ) " + $highlightSize + ";";
- $cmd = $cmd + "setAttr ( $result+\".whitenessR\" ) " + $whitenessR + ";";
- $cmd = $cmd + "setAttr ( $result+\".whitenessG\" ) " + $whitenessG + ";";
- $cmd = $cmd + "setAttr ( $result+\".whitenessB\" ) " + $whitenessB + ";";
- }
- $cmd = $cmd + "setAttr ( $result+\".reflectivity\" ) " + $reflectivity + ";";
-
- $cmd = $cmd + "}";
-
- return $cmd;
- }
-
- global proc string performCreatePhong (int $showOptionBox)
- {
- string $cmd;
-
- if ($showOptionBox == 0) {
- $cmd = getCmd();
- eval($cmd);
- } else if ( $showOptionBox == 1) {
- createPhongOptions;
- } else if ($showOptionBox == 2) {
- $cmd = getCmd();
- }
- return $cmd;
- }
-
-